package uk.co.leandro
{
	import flash.display.DisplayObjectContainer;
	
	import org.robotlegs.mvcs.Context;
	
	import uk.co.leandro.commands.StartGameCommand;
	import uk.co.leandro.commands.StopGameCommand;
	import uk.co.leandro.events.GameEvent;
	import uk.co.leandro.models.GameModel;
	import uk.co.leandro.views.GameView;
	import uk.co.leandro.views.GameViewMediator;
	
	public class GameContext extends Context
	{
		public function GameContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true)
		{
			super(contextView, autoStartup);
		}
		override public function startup():void
		{
			injector.mapSingleton(GameModel);
			mediatorMap.mapView(GameView, GameViewMediator);
			
			commandMap.mapEvent(GameEvent.START, StartGameCommand, GameEvent);
			commandMap.mapEvent(GameEvent.STOP, StopGameCommand, GameEvent);
			
			//add view to main context view (stage)
			var switcherView:GameView = new GameView();
			contextView.addChild(switcherView);
			
			super.startup();
		}
	}
}